package KnightsTour;

public class ChessBoard {

    public final int ROWS = 8, COLUMNS = 8;

    private final Square squares [][];

    public ChessBoard () {
        boolean everyOther = false;
        squares = new Square [ROWS][COLUMNS];
        for (int r = 0; r < ROWS  ; r++ ) {
            everyOther = !everyOther;
            for (int c = 0; c < COLUMNS ; c++ ) {
                if (everyOther) squares[r][c] = new Square(r,c,SquareColour.WHITE);
                else squares[r][c] = new Square (r,c,SquareColour.BLACK);
                everyOther = !everyOther;
            }
        }
    }

    public Square getChessBoardSquare (int row, int column) {
        return squares[row][column];
    }

    public Square [][] getChessBoard () {
        return squares;
    }

    public boolean isOnBoard (int r, int c) {
        return (-1 < r) && (r < ROWS) && (-1 < c) && (c < COLUMNS);
    }

}
